home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Jul 2, 1998
- //<doc>
- //<name tokenizeList>
- //<owner "Alias|Wavefront Unsupported">
- //
- //<synopsis>
- // int tokenizeList( string $list, string $tokenizedList[] )
- //
- //<description>
- // Takes a string $list representing a list of items. The
- // items can be either whitespace- or comma-separated.
- // The individual items in the list are returned as elements
- // of the result array, stored in $tokenizedList.
- //
- //<flags>
- // string $list The string of values to tokenize. Separated by
- // either whitespace or commas.
- // string[] $tokenizedList The items in $list, after tokenization
- //
- //<examples>
- // string $list = "1 6 7, 54";
- // string $tokenizedList[];
- // tokenizeList($list, $tokenizedList);
- // // Result : 1 //
- // print $tokenizedList;
- // <i>1</i>
- // <i>6</i>
- // <i>7</i>
- // <i>54</i>
- //
- //<returns>
- // int : 1 if successful, 0 if unsuccessful
- //
- //</doc>
- //
- global proc int tokenizeList( string $list, string $tokenizedList[] )
- {
- string $regExpr = ",";
- string $replaceWith = " ";
- string $substitutedList = "";
-
- // Remove the commas, if any, and replace them with spaces
- //
- while( $substitutedList != $list ) {
- // Do this only after the first time.
- //
- if( $substitutedList != "" ) {
- $list = $substitutedList;
- }
-
- $substitutedList = `substitute $regExpr $list $replaceWith`;
- }
-
- // Check if $llist is empty.
- //
- if( size( $list ) == 0 ) {
- return 0;
- }
-
- tokenize( $list, $tokenizedList );
-
- return 1;
- }
-
-